<?php
namespace App\Service\Admin\Mall;

class CartService extends BaseService
{
    //购物车

    public static function index()
    {
        $db = self::dbConn(self::$dbMallCart)->where('del', 0);
        $total = $db->count();
        $res = $db->orderBy('id', 'desc')->get();
        if (count($res)) {
            foreach ($res as &$v) {
                $gOne = self::dbConn(self::$dbMallGoods)->where('id', $v->gid)->first();
                $v->gname = $gOne ? $gOne->title : '';
                $v->gcover = $gOne&&file_exists($gOne->cover) ? '/' . $gOne->cover : '';
            }
        }
        return self::toback(0, '', $res, $total);
    }
}